Previous Book Contents Book Index Next

Inside Macintosh: Programming With JManager /
Chapter 1 - Using JManager


Obtaining Java References

In some cases, you may need to access the actual Java objects used in a session, rather than the encapsulated objects passed by the embedding application. For example, if you wanted to call a method contained in an instantiated frame, you would need a reference to the actual Java frame, not the JMFrameRef object. Table 1-2 lists the functions you can use to return Java references. These functions all return a pointer of type jref.

Table 1-2 Functions that return pointers to Java objects
FunctionReturns pointer to object
JMGetSessionObject com.apple.mrj.JManager.JMSession
JMGetAwtContextObject com.apple.mrj.JManager.AWTContext
JMGetAppletViewerObject com.apple.mrj.JManager.JMAppletViewer
JMGetJMFrameObject com.apple.mrj.JManager.JMFrame
JMGetAppletObject java.applet.Applet
JMGetAWTFrameObject java.awt.Frame

The first four functions return the jref equivalents of the corresponding JManager objects. For example, JMGetSessionObject returns the equivalent of the JMSessionRef reference. JMGetAppletObject and JMGetAWTFrameObject, however, return references to their actual Java objects.

You can use these references directly if you are accessing the Java Runtime Interface (JRI), but if you need to access the Java Native Interface (JNI), you must convert references of type jref to ones of type jobject using the JMJRIRefToJNIObject function. To convert references of type jobject to type jref, use the JMJNIObjectToJRIRef function.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
10 DEC 1997